package edu.zut.cs.software.perfect.teacher.service;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import edu.zut.cs.software.perfect.base.service.GenericGenerator;
import edu.zut.cs.software.perfect.teacher.domain.Department;
import edu.zut.cs.software.perfect.teacher.domain.Teacher;

/**
 * @ClassName DepartmentEntityGenerator
 * @Description TODO
 * @Author lixianglong
 * @Date 2020年6月2日 上午12:10:29
 * @Version 1.0
 */
public class DepartmentEntityGenerator extends GenericGenerator{

	TeacherManager teacherManager;
	DepartmentManager departmentManager;
	@Autowired
	public void setTeacherManager(TeacherManager teacherManager) {
		this.teacherManager = teacherManager;
	}
	@Autowired
	public void setDepartmentManager(DepartmentManager departmentManager) {
		this.departmentManager =  departmentManager;
	}
	@Test
	public void testBuild() {
		int num_department=3;
		int num_teacher=3;
		for(int i=0;i<num_department;i++)
		{
			Department department=new Department();
			department.setDepartmentName("departmentName_"+i);
			department.setDepartmentCode("departmentCode_"+i);
			department=this.departmentManager.save(department);
			for(int j=0;j<num_department;j++) {
				Department c = new Department();
				c.setDepartmentName("departmentName_"+i+"_"+j);
				c.setDepartmentCode("departmentCode_"+i+"_"+j);
				c.setParent(department);
				c=this.departmentManager.save(c);
				for(int k=0;k<num_teacher;k++)
				{
					Teacher teacher=new Teacher();
					teacher.setWorkid((long)i+j+k);
					teacher.setDepartmentCode("departmentCode_"+i+"_"+j+"_"+k);
					teacher.setName("name_"+i+"_"+j+"_"+k);
					teacher.setSex("sex_"+i+"_"+j+"_"+k);
					teacher.setAge(i+j);
					teacher.setTeachtitle("teachertitle_"+i+"_"+j+"_"+k);
					teacher.setDepartment(c);
					teacher=this.teacherManager.save(teacher);
					assertNotNull(teacher);
				}
			}
		}
		
	}
	
	
	
}
